<template>
  <div>
    <h3>num数值 ： {{ getNum }}</h3>
    <button @click="incr">++++</button>
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations } from 'vuex'
export default {
  // computed:mapState('count', ['num']),
  computed: {
    // ...mapState('count', ['num'])
    /* ...mapState('count', {
      abc: state => state.num
    }) */

    ...mapGetters('count', ['getNum'])
    // ...mapGetters('count', { num: 'getNum' })

    /* num() {
      // 开启了强制的命名空间
      // state中的数据的获取
      return this.$store.state.count.num
      // return this.$store.getters['count/getNum']
    } */
  },
  methods: {
    // ...mapMutations('count', { addNum: 'addNum' }),
    ...mapMutations('count', ['addNum']),
    incr() {
      // 开启强制命令空间的commit
      // this.$store.commit('count/addNum', 2)
      this.addNum(3)
    }
  }
}
</script>

<style lang="scss" scoped></style>
